/**
 * <pre>
   Copyright 2016 aaron.sd

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 * </pre>
 *
 * @author aaronwong.sd@foxmail.com
 * @version 下午11:41:33
 */
package com.iwechat.httpclient;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.iwechat.mpapi.WeixinException;

/**
 * <p>
 * Title: http响应对象
 * </p>
 *
 * <p>
 * Description:
 * </p>
 *
 * @author aaronwong.sd@foxmail.com
 * @version 1.0
 */
public class Response {

    private int    status  = 200;
    private String dataStr = "";

    public Response() {
    }

    /**
     * 获取返回字符串
     *
     * @return 输出内容
     * @throws WeixinException
     */
    public String asString() {
        return dataStr;
    }

    /**
     * 将返回字符串转换为JSON对象
     *
     * @return JSONObject对象
     * @throws com.iwechat.mpapi.WeixinException
     */
    public JSONObject asJSONObject() throws WeixinException {
        return JSON.parseObject(asString());
    }

    /**
     * 将返回字符串转换为JSONArray对象
     *
     * @return JSONArray对象
     * @throws com.iwechat.mpapi.WeixinException
     */
    public JSONArray asJSONArray() throws WeixinException {
        return JSON.parseArray(asString());
    }

    /**
     * 获取响应状态
     *
     * @return 响应状态
     */
    public int getStatus() {
        return status;
    }

    /**
     * @param status
     *            the status to set
     */
    public void setStatus(int status) {
        this.status = status;
    }

    /**
     * @return the dataStr
     */
    public String getDataStr() {
        return dataStr;
    }

    /**
     * @param dataStr
     *            the dataStr to set
     */
    public void setDataStr(String dataStr) {
        this.dataStr = dataStr;
    }
}
